
/***************************************************************************************************
 *
 * Project: FlashCards
 *
 * Class: ToolBarButtons
 *
 * File name: ToolBarButtons.java
 *
 * May 11, 2008
 *
 **************************************************************************************************/

package com.eastmountain.chinese.gui.controllers;

import java.net.URL;

import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToggleButton;

import com.eastmountain.chinese.main.HZFlashCards;

/*******************************************************************************
 *
 * ToolBarButtons
 *
 ******************************************************************************/

public enum ToolBarButtons {

    //  ToolBarButtons text

    /*******************************************************************************
     *
     * ToolBarButtons
     *
     ******************************************************************************/

    PREVIOUS_LESSON( "Previous Lesson", new JButton(), loadIconImage( "/images/StepBack24.gif" ),
            Tips.PREVIOUS_LESSON_TOOLTIP ),
            PREVIOUS(        "Previous", new JButton(), loadIconImage( "/images/Back24.gif" ),
                    Tips.PREVIOUS_TOOLTIP ),
                    NEXT(            "Next", new JButton(), loadIconImage( "/images/Forward24.gif" ),
                            Tips.NEXT_TOOLTIP ),
                            NEXT_LESSON(     "Next Lesson", new JButton(), loadIconImage( "/images/StepForward24.gif" ),
                                    Tips.NEXT_LESSON_TOOLTIP ),
                                    FLIP(            "Flip", new JButton(), loadIconImage( "/images/Flip24.gif" ),
                                            Tips.FLIP_TOOLTIP ),
                                            REVIEW(          "Question", new JButton(), loadIconImage( "/images/Question24.gif" ),
                                                    Tips.REVIEW_TOOLTIP ),
                                                    SHUFFLE(         "Shuffle", new JButton(), loadIconImage( "/images/W.gif" ),
                                                            Tips.SHUFFLE_TOOLTIP),
                                                            PLAY(            "Play", new JToggleButton(), loadIconImage( "/images/W.gif" ),
                                                                    Tips.PLAY_TOOLTIP);


    private final String buttonName;
    private final AbstractButton toolBarButton;
    private final ImageIcon buttonIcon;
    private final String buttonToolTip;

    ToolBarButtons( String buttonName, AbstractButton toolBarButton, ImageIcon buttonIcon,
            String buttonToolTip ) {

        this.buttonName    = buttonName;
        this.toolBarButton = toolBarButton;
        this.buttonIcon    = buttonIcon;
        this.buttonToolTip = buttonToolTip;

    }

    public String buttonName() {

        return buttonName;

    }

    public AbstractButton toolBarButton() {

        return toolBarButton;

    }

    public ImageIcon buttonIcon() {

        return buttonIcon;

    }

    public String buttonToolTip() {

        return buttonToolTip;

    }

    /***********************************************************************************************
     *
     * loadIconImages
     *
     **********************************************************************************************/

    private static ImageIcon loadIconImage( String imageName ) {

        ImageIcon imageIcon = null;

        // ******* TODO add button graphics to jar

        URL iconURL = HZFlashCards.class.getResource( imageName );

        if ( iconURL != null ) {

            imageIcon = new ImageIcon( iconURL );

        } else {

            System.out.println( "Image not found: " + imageName );

        }

        return imageIcon;

    }

    class Tips {   

        private static final String PREVIOUS_LESSON_TOOLTIP = "Previous lesson";
        private static final String PREVIOUS_TOOLTIP        = "Previous card";
        private static final String NEXT_TOOLTIP            = "Next card";
        private static final String NEXT_LESSON_TOOLTIP     = "Next lesson";
        private static final String FLIP_TOOLTIP            = "Flip card";
        private static final String REVIEW_TOOLTIP          = "Mark for review";
        private static final String SHUFFLE_TOOLTIP         = "Shuffle cards";
        private static final String PLAY_TOOLTIP            = "Play prronunciation drill";

    }

}
